<?php
class Somi_Form_Firmendaten extends Zend_Dojo_Form
{
	public function init()
	{
		
		$this->setName('firmendaten');
		$this->setAction($this->getView()->url())->setMethod('post');
		$this->addAttribs(array('onSubmit'=>'return validate(this)'));
		
		require_once APPLICATION_BASE.'/library/Somi/Validate/ErrorMessageDe.php';
		
		$translateValidators= new Somi_Validate_ErrorMessageDe();
		$translator = new Zend_Translate('array', $translateValidators->getTranslate());
    	Zend_Validate_Abstract::setDefaultTranslator($translator);
    	
    	#$this->clearDecorators();
		$formDecorators=array(
            'FormElements',
        array('HtmlTag',array('tag'=>'dl','class'=>'zend_form')),
            'DijitForm', // hier stand bei dir vorher: 'Form',
        );
                
        
        $elementDecorators=array(
        'DijitElement', // vorher: 'ViewHelper',
        'Errors',
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'element')),
        array('Label',array('class'=>'left','requiredSuffix' => '*')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div','class'=>'row')),
        );
        
        $buttonDecorators=array(
        'DijitElement', // vorher: 'ViewHelper',
        array(array('data'=>'HtmlTag'),array('tag'=>'div','class'=>'button')),
        array(array('row'=>'HtmlTag'),array('tag'=>'div'))
        );  
		
	
		$filterToLower = new Zend_Filter_StringToLower();
        $filterToLower->setEncoding('UTF-8');
        
        
        #Firma
        $firma=$this->createElement('ValidationTextBox','firma',array(
        'label'			=> 'Firma',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. SOMI Solutions GmbH</div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,),
        'validators'	=> array('NotEmpty',), 
        ));
        
        
        #Telefon
        $telefon=$this->createElement('ValidationTextBox','telefon',array(
        'label'			=> 'Telefon',
        'alnum'			=>true,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. 01234 45 67 89 ,<br> (01234) 45 67 89 </div>', 
        'style'			=> 'width:245px;', 
        'regExp'			=>'\(?[0][0-9]+\)?([-. ]?[0-9])*$~i', 
        'validators'		=> array('NotEmpty',),
        ));
        
        
        #Fax
        $fax=$this->createElement('ValidationTextBox','fax',array(
        'label'			=> 'Fax',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. 01234 45 67 89 ,<br> (01234) 45 67 89 </div>', 
        'style'			=> 'width:245px;', 
        'regExp'			=>'\(?[0]{1}[0-9]+\)?([-. ]?[0-9])*$~i',
        #'validators'		=> array(array('regex',false,array('\(?[0]{1}[0-9]+\)?([-. ]?[0-9])*$~i'))),
        ));
        
        #Email
        $email=$this->createElement('ValidationTextBox','email',array(
        'label'			=> 'Email',
        'alnum'			=>false,
        'required'		=> true,
        'PromptMessage'		=> '<div style="width:200px">z.B. info@somi-it.de</div>', 
        'style'			=> 'width:245px;', 
		'validators'	 	=> 	array('NotEmpty',),
        'regExp'			=>'\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b',
        'filters'		=> array($filterToLower,), 
        ));
        
        
        #Website
        $website=$this->createElement('ValidationTextBox','website',array(
        'label'			=> 'Website',
        'alnum'			=>false,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. www.somi-it.de </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,), 
        ));
        
        
        #strasse
        $strasse=$this->createElement('ValidationTextBox','strasse',array(
        'label'			=> 'Strasse',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Kennedyallee 93 </div>', 
        'style'			=> 'width:245px;', 
        #'filter'		=> $filterToLower, 
        ));
        
        
        #Stadt
        $stadt=$this->createElement('ValidationTextBox','stadt',array(
        'label'			=> 'Stadt',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Frankfurt am Main </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,), 
        ));
        
        
        #Ansprechperson
        $ansprechperson=$this->createElement('ValidationTextBox','ansprechperson',array(
        'label'			=> 'Ansprechperson',
        'alnum'			=>true,
        'required'		=> false,
        'PromptMessage'		=> '<div style="width:200px">z.B. Max Muster </div>', 
        'style'			=> 'width:245px;', 
        'filters'		=> array($filterToLower,), 
        ));
        
        
        $submit=$this->createElement('SubmitButton','submit',array(
        'label'			=> 'Senden',
        'style'			=> 'margin-left:308px;width:200px;',
        ));
        
        
        
        $this->addElements(array($firma,$telefon,$fax,$email,$website,$strasse,$stadt,$ansprechperson,$submit));
        
	}
}